<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="style.css">
</head>

<body>
    <script type="text/javascript">
        'use strict';
        function Student(props) {
            this.name = props.name || '暂无名称';//设置名称，以及名称默认值
        }

        Student.prototype.hello = function () {
            alert("hello " + this.name);
        }

        
        function PrimaryStudent(props) {
            Student.call(this, props);
            this.grade = props.grade || 1;
        }

        function F() { }

        F.prototype = Student.prototype;
        PrimaryStudent.prototype = new F();
        PrimaryStudent.prototype.constructor = PrimaryStudent;
        PrimaryStudent.prototype.getGrade = function () {
            return this.grade;
        }
        debugger;
        var xiaoming = new PrimaryStudent({ name: '小明', grade: 2 });
        console.log(xiaoming);
        console.log("xiaoming.__proto__ === PrimaryStudent.prototype :" + (xiaoming.__proto__ === PrimaryStudent.prototype));
        console.log("xiaoming.__proto__.__proto__ === Student.prototype :" + (xiaoming.__proto__.__proto__ === Student.prototype));
        console.log("xiaoming instanceof PrimaryStudent :" + (xiaoming instanceof PrimaryStudent));
        console.log("xiaoming instanceof Student :" + (xiaoming instanceof Student));
    </script>
</body>

</html>